const Vuex = require('vuex');
const Vue = require('vue');
import app from './app';
import themes from './themes';
import user from './user';

Vue.use(Vuex);
export default new Vuex.Store({
  mutations: {
    // 设置窗口最大化、还原
    windowSizeType: (state, {index, type}) => {
      let option = state.app.openAppList[index];
      option.windowSizeType = type;
      console.log(state.themes.themes.taskbar_height.value);
      let barHeight = state.themes.themes.taskbar_height.value;
      let changeOptions;
      if (type === 'max') {
        changeOptions = {
          top: 0, left: 0,
          width: state.themes.clientWidth,
          height: state.themes.clientHeight - barHeight,
        };
      } else if (type === 'initial') {
        changeOptions = {top: 0, left: 0, width: 800, height: 500};
      }
      option.winOption = Object.assign(option.winOption, changeOptions);
      state.app.openAppList = state.app.openAppList.map(item => item);
    },
  },
  modules: {
    app, user, themes
  }
})